package cj.web.marriage.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.activity.domain.SCOrder;

/**
 * 
 * @author 
 *
 */
@DAO
public interface MarriageSCOrderDAO{
	
	@SQL("SELECT a.id,a.openId,b.title,a.orderNo,a.cardNo,a.source,a.status,a.createAt,a.createUser,a.updateAt,a.updateUser,a.prize,a.count,a.printNo FROM SCOrder a left join SCGoods b on a.goodId=b.id WHERE 1=1 #if(:t.orderNo!=null){ AND a.orderNo LIKE '%##(:t.orderNo)%' } #if(:t.status!=null){ AND a.status=:t.status } ORDER BY a.createAt DESC LIMIT :t.start,:t.length ")
    List<Map> query(@SQLParam("t") SCOrder sCOrder);
	
	@SQL("SELECT count(1) FROM SCOrder WHERE 1=1 #if(:t.orderNo!=null){ AND orderNo LIKE '%##(:t.orderNo)%' } #if(:t.status!=null){ AND status=:t.status } ")
    int queryszie(@SQLParam("t") SCOrder sCOrder);
    
    @SQL("select id,openId,goodId,orderNo,cardNo,source,status,createAt,createUser,updateAt,updateUser,prize,count,printNo from SCOrder where id=:1")
    SCOrder queryById(int id);
    
    @SQL("INSERT INTO SCOrder (openId,goodId,orderNo,cardNo,source,status,createAt,createUser,updateAt,updateUser,prize,count,printNo) VALUES (:t.openId,:t.goodId,:t.orderNo,:t.cardNo,:t.source,:t.status,now(),:t.createUser,now(),:t.updateUser,:t.prize,:t.count,:t.printNo)")
    void create(@SQLParam("t") SCOrder sCOrder);
	
	@SQL("UPDATE SCOrder SET status=:t.status,updateAt=now(),source=:t.source,updateUser=:t.updateUser WHERE orderNo=:t.orderNo")
    void updateStatusByOrderNo(@SQLParam("t") SCOrder sCOrder);
}